<?php
class Relative_Model_DefaultModule extends Zend_Db_Table{
	protected $_name = 'default_module_to_page';
	protected $_primary = '';
	/* Link tham khao : http://framework.zend.com/manual/en/zend.db.table.html */
	/* select demo */
	public function selectModuleByCodeInPage($code,$page_code)
	{// co dung
		$client = new Zend_Rest_Client(HTTP_SERVICE);
		$return = $client->restGet("/defaultmoduletopage/route/selectModuleByCode/module_code/".$code."/page_code/".$page_code);
		$return = json_decode(json_encode((array) simplexml_load_string($return->getBody())),1);
		
		for ($i=0;$i <count($return);$i++)
				$data[$i] = $return['row_'.$i];	
		return $data;
	}
	public function selectModuleBySortOrderInPage($sort_order,$page_code)
	{ // co dung
		$client = new Zend_Rest_Client(HTTP_SERVICE);
		$return = $client->restGet("/defaultmoduletopage/route/selectModuleBySortOrderInPage/sort_order/".$sort_order."/page_code/".$page_code);
		$return = json_decode(json_encode((array) simplexml_load_string($return->getBody())),1);
		
		for ($i=0;$i <count($return);$i++)
				$data[$i] = $return['row_'.$i];	
		return $data;
	}	
		
	/* update demo */
	public function updateModule($module_code,$page_code,$sort)
	{// co dung
	$client = new Zend_Rest_Client(HTTP_SERVICE);
		$return = $client->resetPut("/defaultmoduletopage/route/updateDefaultModuleToPage/sort/".$sort."/module_code/".$module_code."/page_code/".$page_code);
		return $return->getBody();
	}
	
}